<template>
  <el-dropdown trigger="click" @command="changeLanguage">
    <div>
      <svg-icon icon-class="language"/>
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh-CN" :disabled="'zh-CN'=== $i18n.locale ">简体中文</el-dropdown-item>
      <el-dropdown-item command="en-US" :disabled="'en-US'=== $i18n.locale ">English</el-dropdown-item>
      <el-dropdown-item command="zh-TW" :disabled="'zh-TW'=== $i18n.locale ">繁体中文</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  methods: {
    changeLanguage(lang) {
      this.$i18n.locale = lang // 设置给本地的i18n插件
      this.$message.success('切换多语言成功')
    }
  }
}
</script>
